package huoye.shops.huoye.user.network;



import android.util.Log;

import com.codeideology.android.http.okhttp.OkHttpUtils;
import com.codeideology.android.lang.entity.Paging;
import com.codeideology.android.rpc.BaseJsonRequestCallback;
import com.codeideology.android.utils.StringUtils;

import java.util.HashMap;
import java.util.Map;

import huoye.shops.base.APIUrls;
import huoye.shops.base.BaseService;
import huoye.shops.base.MineBaseJsonRequestCallback;
import huoye.shops.base.UserManager;
import huoye.shops.base.ZybCallBack;
import huoye.shops.common.model.SMSCoder;
import huoye.shops.huoye.mine.model.ShopDetials;
import huoye.shops.huoye.operation.model.SellOrder;
import huoye.shops.huoye.user.model.AreaInfo;
import huoye.shops.huoye.user.model.CityData;
import huoye.shops.huoye.user.model.SelectCityData;
import huoye.shops.huoye.user.model.UpdateInfo;
import huoye.shops.huoye.user.model.User;


/**
 * Created by user on 2017/7/24.
 */

public class UserService extends BaseService {

    /**
     *  App商家登录
     *
     * @param mobile
     * @param smsId
     * @param smsCode
     * @param callback
     */
    public void login(String mobile, String smsId,String smsCode, MineBaseJsonRequestCallback<User> callback) {
       Map<String, String> param = new HashMap<>();
        param.put("mobile", mobile);
        param.put("smsId", smsId);
        param.put("smsCode",smsCode);

        OkHttpUtils.getInstance().post()
                .url(getUrl(APIUrls.USER.TYPE_USER_SHOP_LOGIN))
                .params(param)
                .build().execute(callback);
    }




    /**
     *  短信验证
     *
     * @param tel
     * @param callback
     */
    public void sendRestPasswordSms(String tel, MineBaseJsonRequestCallback<SMSCoder> callback) {

        Map<String, String> param = new HashMap<>();

        param.put("mobile", tel);
        param.put("sendType", "2");


        OkHttpUtils.getInstance().post()
                .url(getUrl(APIUrls.COMMON_CONFIG.TYPE_COMMON_SMS_CODE_URL))
                .params(param)
                .build().execute(callback);


    }


    /**
     *  获取代理商接口地址信息
     *
     * @param province
     * @param city
     * @param district
     * @param callback
     */
    public void selectCity(String province,String city,String district, MineBaseJsonRequestCallback<SelectCityData> callback) {

        Map<String, String> param = new HashMap<>();

        param.put("province", province);
        param.put("city",city);
        param.put("district", district);


        OkHttpUtils.getInstance().post()
                .url(APIUrls.COMMON_CONFIG.TYPE_COMMON_AGENT_INFO)
                .params(param)
                .build().execute(callback);


    }


 /**
     *  获取省市区3级联动
     *
     * @param ftype
     * @param areaname
     * @param callback
     */
    public void getAreaInfo(String ftype,String areaname,MineBaseJsonRequestCallback<CityData> callback) {

        Map<String, String> param = new HashMap<>();

        param.put("ftype", ftype);
        if(StringUtils.isNotEmpty(areaname)){
            param.put("areaname",areaname);
        }



        OkHttpUtils.getInstance().get()
                .url(APIUrls.COMMON_CONFIG.TYPE_COMMON_GET_AREA_INFO)
                .params(param)
                .build().execute(callback);


    }








    //检测升级
    public void checkUpdate( MineBaseJsonRequestCallback<UpdateInfo> callback) {
        Map<String, String> param = new HashMap<>();
        param.put("apptype","1");

        OkHttpUtils.getInstance().get()
                .url(APIUrls.COMMON_CONFIG.TYPE_COMMON_APP_VERSION)
                .params(param)
                .build().execute(callback);
    }







}


